package test.luin.pers.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class ListViewActivity extends AppCompatActivity {

    ListView lv_apps;
    List<App> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_view);
        init();
        MyAdapter myAdapter = new MyAdapter(list, this);
        lv_apps.setAdapter(myAdapter);
    }

    void init() {
        lv_apps = findViewById(R.id.lv_apps);
        //初始化数据
        list = new ArrayList<App>();
        list.add(new App("京东", R.drawable.jd));
        list.add(new App("QQ", R.drawable.qq));
        list.add(new App("QQ斗地主", R.drawable.dz));
        list.add(new App("新浪微博", R.drawable.xl));
        list.add(new App("天猫", R.drawable.tm));
        list.add(new App("UC浏览器", R.drawable.uc));
        list.add(new App("微信", R.drawable.wx));
    }
}
